package com.example.common.util.exception;


import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 基础异常
 *
 * @author ruoyi
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BaseException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    /**
     * 所属模块
     */
    private String module;

    /**
     * 错误码
     */
    private String code;

    /**
     * 错误码对应的参数
     */
    private Object[] args;

    /**
     * 错误消息
     */
    private String defaultMessage;

    public BaseException(String module, String code, Object[] args, String defaultMessage)
    {
        this.module = module;
        this.code = code;
        this.args = args;
        this.defaultMessage = defaultMessage;
    }

    public BaseException(String module, String code, Object[] args)
    {
        this(module, code, args, null);
    }


    public BaseException(String code,String defaultMessage){
        this(null,code,null,defaultMessage);
    }



    public BaseException(String defaultMessage)
    {
        this(null, null, null, defaultMessage);
    }

    @Override
    public String getMessage() {
        return super.getMessage();
    }

}
